home *** CD-ROM | disk | FTP | other *** search
/ ftp.hitl.washington.edu / ftp.hitl.washington.edu.tar / ftp.hitl.washington.edu / pub / people / tsoper / My Sample Apps / OpenGLApp / OpenGLPanel.cs < prev   
Text File  |  2005-05-08  |  2KB  |  70 lines

  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4. using CsGL.OpenGL;
  5.  
  6. class AnotherForm : Form
  7. {
  8.     View view = new View();
  9.     private System.Windows.Forms.Panel panel;
  10.  
  11.     public AnotherForm(Form parentForm)
  12.     {
  13.         this.Text = "Another Form";
  14.         this.MdiParent = parentForm;
  15.     
  16.         this.panel = new System.Windows.Forms.Panel();
  17.         this.panel.Controls.AddRange(
  18.             new System.Windows.Forms.Control[] { view });
  19.  
  20.         this.Controls.AddRange(
  21.             new System.Windows.Forms.Control[] {this.panel });
  22.  
  23.         panel.BorderStyle = BorderStyle.Fixed3D;
  24.  
  25.         view.Dock = DockStyle.Fill;
  26.         this.panel.Dock = DockStyle.Fill;
  27.  
  28.         this.Dock = DockStyle.Fill;
  29.  
  30.         this.TopMost = true;
  31.         this.Show();
  32.     }
  33. }
  34.  
  35. class View : OpenGLControl
  36. {
  37.     public override void glDraw()
  38.     {
  39.         GL.glClear( GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT ); // Clear Screen And Depth Buffer
  40.         GL.glBegin( GL.GL_POINTS );
  41.         GL.glVertex2i( 100, 50 );
  42.         GL.glVertex2i( 100, 130 );
  43.         GL.glVertex2i( 150, 130 );
  44.         GL.glEnd();
  45.         GL.glFlush();
  46.     }
  47.     protected override void InitGLContext()
  48.     {
  49.         GL.glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
  50.         GL.glColor3f( 1.0f, 0.0f, 0.0f );
  51.         GL.glPointSize( 4.0f );
  52.     }
  53.     protected override void OnSizeChanged(EventArgs e)
  54.     {
  55.         base.OnSizeChanged(e);
  56.         GL.glMatrixMode(GL.GL_PROJECTION);
  57.         GL.glLoadIdentity();
  58.         GL.gluOrtho2D( 0.0, Size.Width, 0.0, Size.Height );
  59.     }
  60. }
  61.  
  62. class SampleApp
  63. {
  64.     static void Main()
  65.     {
  66.         Form form = new SampleForm();
  67.         Application.Run(form);
  68.     }
  69. }
  70.